package com.example.testspringboot.controller;

import com.example.testspringboot.entity.User;
import com.example.testspringboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userController")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/queryUserName")
    public String queryUserName() {
        return "张三";
    }

    @GetMapping("/queryUserName2")
    public String queryUserName(@RequestParam String name) {

        if (name.equals("张三")) {
            return "用户名字为张三，24岁，湖南人长沙人";
        } else {
            return "没查到该用户信息";
        }


        //        String sex2 = "EFGH";
////        sex2.toLowerCase();//将数据改为全小写
//        sex2.isEmpty();//是否为空
//        sex2.equals();//是否相等
//        sex2.contains();//是否包含
//        sex2.isBlank();//是否为Null或为空
//        return sex2.toLowerCase();//将数据改为全大写
    }

    @GetMapping("/getUserInfo")
    public List<User> getUserInfo() {
        List<User> user = userService.getUserInfo();
         return user;
    }


    @GetMapping("/queryUserId")
    public User queryUserId(@RequestParam String id) {
        return userService.queryUserId(id);


    }

    @GetMapping("/findByName")
    public User findByName(@RequestParam String name) {
        return userService.findByName(name);
    }

}
